<template>
  <el-row :gutter="20">
    <el-col :span="16">
      <set-table @post="handlePost" @showTree="handleShowTree" ref="setTable" />
    </el-col>
    <el-col :span="8">
      <tree-part @setArr="handleSetArr" ref="treePart" />
    </el-col>
  </el-row>
</template>

<script>
import SetTable from './Table'
import TreePart from './Tree'

export default {
  components: {
    SetTable,
    TreePart
  },
  methods: {
    handlePost(arr) {
      console.log('post arr', arr)

      if (arr.length > 0) {
        this.$emit('postData', true, arr, 2)
      } else {
        this.$message.error('请至少增加一条数据')
        this.$emit('notSubmit', 2)
      }
    },
    setType(num) {
      console.log('planType', num)
      this.$refs.setTable.setType(num)
      this.$refs.treePart.setType(num)
    },
    postData() {
      // 点击下一步时，获取表格数据
      this.$refs.setTable.getData()
    },
    handleShowTree(obj) {
      this.$refs.treePart.handleEdit(obj)
    },
    handleSetArr(arr) {
      this.$refs.setTable.pushData(arr)
    }
  }
}
</script>
